<?php
//客户管理类
class OrderAction extends CommonAction {
	public function index() {
		parent::userauth2(108);
		$data['pageSize'] = 8;
		$data['start'] = empty($_GET['page'])?1:($_GET['page']);
		$data['status'] = !isset($_GET['s'])?' ':$_GET['s'];
		if (!empty($_GET['userName'])) {
			$data['userName']=$_GET['userName'];
		}
		if (!empty($_GET['telephone'])) {
			$data['telephone']=$_GET['telephone'];
		}
		if (!empty($_GET['orderName'])) {
			$data['orderName']=$_GET['orderName'];
		}
		//http://139.196.194.93:8080/smart/order/manager/OrderRecordList
		$html = send_post(C('SMART_URL').'/smart/order/manager/OrderRecordList',$data);
		$count = $html['data']['pageInfo']['totalRowNumber'];
		$user = $html['data']['pageInfo']['dataList'];
		
		import('ORG.Util.Page');				// 导入分页类
		$pagenum = isset ( $_REQUEST ['page'] ) ? $_REQUEST ['page'] : 1;
		$page_row = $data['pageSize'];//每页显示条数
		//dump($count);
		$p = new Page ($count,$page_row,8);
		$p->isJumpPage = true;
		$p->setConfig('theme','%totalRow% %header% %nowPage%/%totalPage% 页%first% %upPage% %linkPage% %downPage% %end% %jump%');
		$show = $p->show();
		//dump($show);
		$this->assign('user',$user);
		// $this->assign('maxpage',$maxpage);

		$this->assign('userName',$data['userName']);
		$this->assign('telephone',$data['telephone']);
		$this->assign('orderName',$data['orderName']);

		$this->assign('page',$show);
		$this->assign('newsurl',C('NEWSURL'));
		$this->assign('url',C('URL'));
		$this->assign('admin',$_SESSION['ThinkUser']);

		$this->assign('status', D('status')->field('id, name, value')->order('id asc')->where('pid = 3')->select());

		$this->display();
	}

	public function closeOrder($value='')
	{
		//验证用户权限
		parent::userauth(20);
		//判断是否是ajax请求
		if ($this->isAjax()) {
			if (I('post.post','') == 'ok') {
				$id = I('post.id','');
				$data['orderId']=$id;
				$html = send_post(C('SMART_URL').'/smart/order/manager/cancelOrder',$data);
				/*{
				"code": "5000",
				"data": null,
				"extraData": { },
				"message": "订单不存在",
				"module": null,
				"success": false
			}*/
					/*{
					"code": "2000",
					"data": null,
					"extraData": { },
					"message": "修改成功",
					"module": null,
					"success": true
				}*/
				$return['code']=1;
				$return['mes']=$html['message'];
				parent::operating(__ACTION__,0,'关闭订单成功');
				R('Public/errjson',array('ok'));
			}else {
				parent::operating(__ACTION__,1,'非法请求');
				R('Public/errjson',array('非法请求'));
			}
		}else {
			parent::operating(__ACTION__,1,'非法请求');
			R('Public/errjson',array('非法请求'));
		}
	}
}
?>

